<template>
    <div></div>
</template>

<script>
import { nodeTree } from '@/view/network/modules/treeData.js'
export default {
  name: 'test',
  data() {
    return {
      nodeTree
    }
  },
  methods: {
    deepFirst(array) {
      const loop = (list) => {
        list.forEach(item => {
          if (item.children) {
            loop(item.children)
          }
          console.log(item.label)
          console.log(item.id)
        })
      }
      loop(array)
    },
    deepFirstUseQueue(array) {
      const queue = array.slice()
      let node = queue.shift()
      while (node) {
        if(node && node.children && node.children.length){
          queue.unshift(...node.children)
        }
        console.log(node.id)
        node = queue.shift()
      }

    },
    widthFirst(array) {
      const queue = array.slice()
      let node = queue.shift()
      while (node) {
        if(node && node.children && node.children.length){
          queue.push(...node.children)
        }
        console.log(node.id)
        node = queue.shift()
      }
    },
    log99() {
      for (let i = 1; i <= 9; i++) {
        let str = ''
        for (let j = 1; j <= i; j++) {
          str += `${i}x${j}=${i * j}` + ' '
        }
        console.log(str)
      }
    }
  },
  mounted() {
    // this.deepFirstUseQueue(nodeTree)
    this.log99()
    // this.widthFirst(nodeTree)
  }
}
</script>

<style scoped>

</style>